<script src="http://laymi-assets.oss-cn-shanghai.aliyuncs.com/js/jquery-2.1.4/jquery.min.js"></script>
<script type="text/javascript" src="http://laymi-assets.oss-cn-shanghai.aliyuncs.com/js/layui-v1.0.9/layui.js"></script>
<script type="text/javascript" src="http://laymi-assets.oss-cn-shanghai.aliyuncs.com/js/jquery-1.11.3/jquery.form-2.82.js"></script>
<link rel="stylesheet" href="js/layui/css/layui.css"  media="all">
<script type="text/javascript" src="/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="/js/ueditor/ueditor.all.min.js"></script>
<script>
layui.use(['form','laydate'], function(){
	var form = layui.form();
	var laydate = layui.laydate;
});
</script>
###当前日期时间Two(范围)
#define input_date_time_rangeTwo(name,title)
<label class="layui-form-label">#(title)</label>
    <div class="layui-input-inline">
      <input  name="#(name)" class="layui-input" placeholder="开始日" id="LAY_time_range_s">
    </div>
    <div class="layui-input-inline">
      <input  name="#(name)" class="layui-input" placeholder="截止日" id="LAY_time_range_e">
    </div>
<script>
layui.use('laydate', function(){
  var laydate = layui.laydate;
  
  var start = {
    min: laydate.now()
    ,istime: true//是否开启时间选择
    ,max: '2099-06-16 23:59:59'
    , format: 'YYYY-MM-DD hh:mm:ss'
    ,istoday: false
    ,choose: function(datas){
      end.min = datas; //开始日选好后，重置结束日的最小日期
      end.start = datas //将结束日的初始值设定为开始日
    }
  };
  
  var end = {
    min: laydate.now()
    ,max: '2099-06-16 23:59:59'
    ,istime: true//是否开启时间选择
    , format: 'YYYY-MM-DD hh:mm:ss'
    ,istoday: false
    ,choose: function(datas){
      start.max = datas; //结束日选好后，重置开始日的最大日期
    }
  };
  
  document.getElementById('LAY_time_range_s').onclick = function(){
    start.elem = this;
    laydate(start);
  }
  document.getElementById('LAY_time_range_e').onclick = function(){
    end.elem = this
    laydate(end);
  }
  
});
</script>
#end
###当前日期Two(范围)
#define input_date_rangeTwo(name,title)
<label class="layui-form-label">#(title)</label>
    <div class="layui-input-inline">
      <input  name="#(name)" class="layui-input" placeholder="开始日" id="LAY_range_s">
    </div>
    <div class="layui-input-inline">
      <input  name="#(name)" class="layui-input" placeholder="截止日" id="LAY_range_e">
    </div>
<script>
layui.use('laydate', function(){
  var laydate = layui.laydate;
  
  var start = {
    min: laydate.now()
    ,max: '2099-06-16 23:59:59'
    ,istoday: false
    ,choose: function(datas){
      end.min = datas; //开始日选好后，重置结束日的最小日期
      end.start = datas //将结束日的初始值设定为开始日
    }
  };
  
  var end = {
    min: laydate.now()
    ,max: '2099-06-16 23:59:59'
    ,istoday: false
    ,choose: function(datas){
      start.max = datas; //结束日选好后，重置开始日的最大日期
    }
  };
  
  document.getElementById('LAY_range_s').onclick = function(){
    start.elem = this;
    laydate(start);
  }
  document.getElementById('LAY_range_e').onclick = function(){
    end.elem = this
    laydate(end);
  }
  
});
</script>
#end
###当前日期(范围)
#define input_date_rangex(name,title,min,max)
<label class="layui-form-label">#(title)</label>
<div class="layui-input-inline">
  <input class="layui-input"  name="#(name)" placeholder="只能选昨天到明天" onclick="layui.laydate({elem: this, min: laydate.now(-#(min)), max: laydate.now(+#(max))})">
</div>
#end
###当前日期带节日
#define input_date_festival(name,title)
<label class="layui-form-label">#(title)</label>
<div class="layui-input-inline">
  <input class="layui-input" name="#(name)" placeholder="请输入#(title)" onclick="layui.laydate({elem: this, festival: true})">
</div>
#end
###当前日期时间(YYYY-MM-DD hh:mm:ss)
#define input_date_time(name,title)
<label class="layui-form-label">#(title)</label>
<div class="layui-input-inline">
<input class="layui-input" name="#(name)" placeholder="请输入#(title)" onclick="layui.laydate({elem: this, istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
</div>
#end

###文本域
#define input_areatext(name,title)
<label class="layui-form-label">#(title)</label>
<div class="layui-input-block">
<textarea name="#(name)" required lay-verify="required" placeholder="请输入#(title)" class="layui-textarea"></textarea>
</div>
#end
###单选框
#define input_radio(name,title,table,code,text)
<label class="layui-form-label">#(title)</label>
<div id="#(name)_radio_view" class="layui-input-block">
</div>
<script id="#(name)_radio" type="text/html">
{{#  layui.each(d, function(index, item){ }}
<input type="radio" name="#(name)" value="{{item.#(code)}}" title="{{item.#(text)}}" checked>
{{#  }); }}
</script>
<script type="text/javascript">
$.ajax({
    url:'/g/fD',
    type:'POST', //GET
    async: false,
    data:{"table":'#(table)',"code":'#(code)',"text":'#(text)'},
    dataType:'json',    //返回的数据格式：json/xml/html/script/jsonp/text
    success:function(data,textStatus,jqXHR){
    	layui.use('laytpl', function(){
    		  var laytpl = layui.laytpl;
    		  var getTpl = #(name)_radio.innerHTML;
			     laytpl(getTpl).render(data, function(html){
			     $("##(name)_radio_view").html(html);
    		    }); 
        });
    }
});
</script>
#end

###中文开关
#define input_checkbox_switch_CN(name,title,table,code,text)
<label class="layui-form-label">#(title)</label>
<div id="#(name)_checkbox_switch_CN_view" class="layui-input-block">
</div>
<script id="#(name)_checkbox_switch_CN" type="text/html">
{{#  layui.each(d, function(index, item){ }}
<input type="checkbox" name="#(name)" value="{{item.#(code)}}" lay-skin="switch" lay-text="开启|关闭" checked>
{{#  }); }}
</script>
<script type="text/javascript">
$.ajax({
    url:'/g/fD',
    type:'POST', //GET
    async: false,
    data:{"table":'#(table)',"code":'#(code)',"text":'#(text)'},
    dataType:'json',    //返回的数据格式：json/xml/html/script/jsonp/text
    success:function(data,textStatus,jqXHR){
    	layui.use('laytpl', function(){
    		  var laytpl = layui.laytpl;
    		  var getTpl = #(name)_checkbox_switch_CN.innerHTML;
			     laytpl(getTpl).render(data, function(html){
			     $("##(name)_checkbox_switch_CN_view").html(html);
    		    }); 
        });
    }
});
</script>
#end
###英文文开关
#define input_checkbox_switch_EN(name,title,table,code,text)
<label class="layui-form-label">#(title)</label>
<div id="#(name)_checkbox_switch_EN_view" class="layui-input-block">
</div>
<script id="#(name)_checkbox_switch_EN" type="text/html">
{{#  layui.each(d, function(index, item){ }}
<input type="checkbox" name="#(name)" value="{{item.#(code)}}" lay-skin="switch" lay-text="ON|OFF" checked>
{{#  }); }}
</script>
<script type="text/javascript">
$.ajax({
    url:'/g/fD',
    type:'POST', //GET
    async: false,
    data:{"table":'#(table)',"code":'#(code)',"text":'#(text)'},
    dataType:'json',    //返回的数据格式：json/xml/html/script/jsonp/text
    success:function(data,textStatus,jqXHR){
    	layui.use('laytpl', function(){
    		  var laytpl = layui.laytpl;
    		  var getTpl = #(name)_checkbox_switch_EN.innerHTML;
			     laytpl(getTpl).render(data, function(html){
			     $("##(name)_checkbox_switch_EN_view").html(html);
    		    }); 
        });
    }
});
</script>
#end
###原始风格复选框
#define input_checkbox_primary(name,title,table,code,text)
<label class="layui-form-label">#(title)</label>
<div id="#(name)_checkbox_primary_view" class="layui-input-block">
</div>
<script id="#(name)_checkbox_primary" type="text/html">
{{#  layui.each(d, function(index, item){ }}
<input type="checkbox" name="#(name)" value="{{item.#(code)}}" title="{{item.#(text)}}"  lay-skin="primary" checked>
{{#  }); }}
</script>
<script type="text/javascript">
$.ajax({
    url:'/g/fD',
    type:'POST', //GET
    async: false,
    data:{"table":'#(table)',"code":'#(code)',"text":'#(text)'},
    dataType:'json',    //返回的数据格式：json/xml/html/script/jsonp/text
    success:function(data,textStatus,jqXHR){
    	layui.use('laytpl', function(){
    		  var laytpl = layui.laytpl;
    		  var getTpl = #(name)_checkbox_primary.innerHTML;
			     laytpl(getTpl).render(data, function(html){
			     $("##(name)_checkbox_primary_view").html(html);
    		    }); 
        });
    }
});
</script>
#end
###默认风格复选框
#define input_checkbox_default(name,title,table,code,text)
<label class="layui-form-label">#(title)</label>
<div id="#(name)_checkbox_default_view" class="layui-input-block">
</div>
<script id="#(name)_checkbox_default" type="text/html">
{{#  layui.each(d, function(index, item){ }}
<input type="checkbox" name="#(name)" value="{{item.#(code)}}" title="{{item.#(text)}}" checked>
{{#  }); }}
</script>
<script type="text/javascript">
$.ajax({
    url:'/g/fD',
    type:'POST', //GET
    async: false,
    data:{"table":'#(table)',"code":'#(code)',"text":'#(text)'},
    dataType:'json',    //返回的数据格式：json/xml/html/script/jsonp/text
    success:function(data,textStatus,jqXHR){
    	layui.use('laytpl', function(){
    		  var laytpl = layui.laytpl;
    		  var getTpl = #(name)_checkbox_default.innerHTML;
			     laytpl(getTpl).render(data, function(html){
			     $("##(name)_checkbox_default_view").html(html);
    		    }); 
        });
    }
});
</script>
#end
###下拉选
#define input_select(name,title,table,code,text)
<label class="layui-form-label">#(title)</label>
<div class="layui-input-inline">
<select name="#(name)" id="#(name)_select_view"  lay-verify="required" lay-search>
</select>
</div>
<script id="#(name)_select" type="text/html">
       <option value="">选择#(title)可搜索</option>
{{#  layui.each(d, function(index, item){ }}
        <option value="{{item.#(code)}}">{{item.#(text)}}</option>
{{#  }); }}
</script>
<script type="text/javascript">
$.ajax({
    url:'/g/fD',
    type:'POST', //GET
    async: false,
    data:{"table":'#(table)',"code":'#(code)',"text":'#(text)'},
    dataType:'json',    //返回的数据格式：json/xml/html/script/jsonp/text
    success:function(data,textStatus,jqXHR){
    	layui.use('laytpl', function(){
    		  var laytpl = layui.laytpl;
    		  var getTpl = #(name)_select.innerHTML;
			     laytpl(getTpl).render(data, function(html){
			     $("##(name)_select_view").html(html);
    		    }); 
        });
    }
});
</script>
#end
###密码输入框
#define input_password(name,title)
   <label class="layui-form-label">#(title)</label>
  <div class="layui-input-inline">
  <input type="password" name="#(name)" required lay-verify="" placeholder="请输入#(title)" autocomplete="off" class="layui-input"> 
  </div>
#end
###普通输入框
#define input_text(name,title)
   <label class="layui-form-label">#(title)</label>
  <div class="layui-input-inline">
   <input  type="text" name="#(name)" placeholder="请输入#(title)" autocomplete="off" class="layui-input">
  </div>
#end
###富文本编辑器-秀米
#define ueditor_xiumi(name,title)
<!-- 加载富文本编辑器 -->
<label class="layui-form-label">#(title)</label>
<div class="layui-input-block">
<script id="container_xiumi" name="#(name)" type="text/plain"></script>
</div>
<script type="text/javascript" src="/js/ueditor/dialogs/xiumi-ue-dialog-v5.js"></script> 
<script type="text/javascript">
	// 加载 ueditor，传入的初始化参数可以覆盖掉 ueditor.config.js 中的配置
	// 对于同一项目中使用不同的配置的 ueditor 场景非常有用
	var ue = UE.getEditor('container_xiumi', {
		initialFrameHeight:300
		// , initialFrameWidth:796
		,wordCount:false
	});

	// 由于ctrl+回车提交表单会让ajax form失效，所以让该快捷键失效
	// $(document).ready(function() {ue.shortcutkeys["autosubmit"] = "";});
	// 另一种让该表单提交快捷键失效的方法，注册同名plugin覆盖掉旧的，这种方式更加简单可靠
	UE.plugin.register('autosubmit',function(){});

	UE.plugin.register('jfajaxsubmit',function(){
		return {
			shortcutkey:{
				"jfajaxsubmit":"ctrl+13" // ctrl + 回车 提交表单
			},
			commands:{
				'jfajaxsubmit':{
					execCommand:function () {
						var me=this;
						if(me.fireEvent("beforesubmit")===false){
							return;
						}
						me.sync();
						$("#myArticleForm").submit();
					}
				}
			}
		}
	});
	ue.ready(function() {
		ue.execCommand('serverparam', {
			'uploadType': 'feedback'
		});
	});
</script>
#end
###富文本编辑器
#define ueditor(name,title)
<!-- 加载富文本编辑器 -->
<label class="layui-form-label">#(title)</label>
<div class="layui-input-block">
<script id="container" name="#(name)" type="text/plain"></script>
</div>
<script type="text/javascript">
	// 加载 ueditor，传入的初始化参数可以覆盖掉 ueditor.config.js 中的配置
	// 对于同一项目中使用不同的配置的 ueditor 场景非常有用
	var ue = UE.getEditor('container', {
		initialFrameHeight:300
		// , initialFrameWidth:796
		,wordCount:false
	});

	// 由于ctrl+回车提交表单会让ajax form失效，所以让该快捷键失效
	// $(document).ready(function() {ue.shortcutkeys["autosubmit"] = "";});
	// 另一种让该表单提交快捷键失效的方法，注册同名plugin覆盖掉旧的，这种方式更加简单可靠
	UE.plugin.register('autosubmit',function(){});

	UE.plugin.register('jfajaxsubmit',function(){
		return {
			shortcutkey:{
				"jfajaxsubmit":"ctrl+13" // ctrl + 回车 提交表单
			},
			commands:{
				'jfajaxsubmit':{
					execCommand:function () {
						var me=this;
						if(me.fireEvent("beforesubmit")===false){
							return;
						}
						me.sync();
						$("#myArticleForm").submit();
					}
				}
			}
		}
	});
	ue.ready(function() {
		ue.execCommand('serverparam', {
			'uploadType': 'feedback'
		});
	});
</script>
#end